package orthoplanner.com.google.code.ui;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.SwingConstants;
import javax.swing.border.TitledBorder;

import orthoplanner.com.google.code.eventhandlers.ImageScaleSliderHandler;
import orthoplanner.com.google.code.eventhandlers.ScaleResetHandler;


public class ScalePanel extends JPanel {
	private static final long serialVersionUID = 8428295617568955541L;
	private JButton bScaleReset;
	private JSlider slScale;

	public ScalePanel(ImageViewer imgViewer) {
		setFont( new Font("SansSerif", Font.BOLD, 12));
		setPreferredSize(new Dimension(200, 80));
		bScaleReset = new JButton("Reset");
		bScaleReset.setFont( new Font("SansSerif", Font.BOLD, 12));
		slScale = new JSlider(SwingConstants.HORIZONTAL, 1, 1000, 500);
		bScaleReset.addMouseListener(new ScaleResetHandler(slScale));
		setLayout(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.weightx = 1.0;
		gbc.weighty = 1.0;
		gbc.anchor = GridBagConstraints.LAST_LINE_END;
		add(bScaleReset, gbc);
		gbc.fill = GridBagConstraints.HORIZONTAL;
		gbc.gridy = 1;
		add(slScale, gbc);
		slScale.addChangeListener(new ImageScaleSliderHandler(imgViewer));
		setBorder(new TitledBorder("Scale"));
	}

	public JButton getbScaleReset() {
		return bScaleReset;
	}

	public JSlider getSlScale() {
		return slScale;
	}
}
